package com.wanxi.filter;

/**
 * 登录认证过滤器：
 * 1、不能拦截登录接口
 * 2、登录之后所有 接口都需要拦截
 * */
//@WebFilter("/back/*")
//public class LoginFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        HttpServletResponse response = (HttpServletResponse) servletResponse;
//        HttpSession session = request.getSession();
//        Object user = session.getAttribute(Tool.USER_LOGIN_INFO);
//        /**
//         * 在进行判定时，尽量较少无效判定
//         * */
//        if(user != null){
//            filterChain.doFilter(request, response);
//            return;
//        }
//        response.getWriter().write(JSONObject.toJSONString(ResultModel.error()));
//        /*if(user == null){ //为登录
//            response.getWriter().write(JSONObject.toJSONString(ResultModel.error()));
//            return;
//        } else {
//            filterChain.doFilter(request, response);
//        }*/
//    }
//
//    @Override
//    public void destroy() {
//
//    }
//}